/*
 * RollingAvg.h
 *
 *  Created on: Jan 26, 2013
 *      Author: Drew Prevost
 */

#ifndef ROLLINGAVG_H_
#define ROLLINGAVG_H_

#ifndef NUM_HISTORY_ENTRIES
#define NUM_HISTORY_ENTRIES 10
#endif

class RollingAvg
{
public:
  // functions
  RollingAvg();

  double getAverage();
  void add( double nNewValue );
  void reset();
  double getLast();

protected:
  //functions
  void _refreshAverage();

protected:
  // data members
  unsigned int nCurIndex;
  double arrHistory[NUM_HISTORY_ENTRIES];
  double nCurAvg;
  double nLast;
  bool bCurAvgDirty;
};

#endif /* ROLLINGAVG_H_ */
